package com.example.hellomap;

import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.widget.DatePicker;
import android.app.DatePickerDialog;
import android.app.Dialog;

public class MyDatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
		
	@Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current date as the default date in the picker
		MainActivity a = (MainActivity)getActivity();
        
        int year = a.getDate().getYear();
        int month = a.getDate().getMonth();
        int day = a.getDate().getDay();

        // Create a new instance of DatePickerDialog and return it
        return new DatePickerDialog(getActivity(), this, year, month, day);
    }
	
	@Override
	public void onDateSet(DatePicker view, int year, int month, int day) {
		MainActivity a = (MainActivity)getActivity();
		a.setDate(year, month, day);
		//Toast.makeText(getActivity(), year + "-" + (month+1) + "-" + day, Toast.LENGTH_LONG).show();
	}

	
}
